#include<iostream>
using namespace std;

const int N = 10;
const int n = 9;
int a[N][N];
bool col[N][N],row[N][N],st[N][N][N];

bool dfs(int i, int j){
	if(j == n){
		i++;
		j = 0;
	}
	if(i == n){
		return true;
	}
	if(a[i][j]) return dfs(i,j+1);
	
	for(int x = 1; x <= 9; x++){
		if(col[i][x] || row[j][x] || st[i / 3][j / 3][x]) continue;
		a[i][j] = x;
		col[i][x] = row[j][x] = st[i / 3][j / 3][x] = true;
		if(dfs(i, j+1)) return true;
		col[i][x] = row[j][x] = st[i / 3][j / 3][x] = false;
		a[i][j] = 0;
	}
	return false;
}

int main(){
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
			int x = a[i][j];
			if(a[i][j]){
				col[i][x] = row[j][x] = st[i / 3][j / 3][x] = true;
			}
		}
	}
	
	dfs(0,0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << a[i][j] <<" ";
		}
		cout << endl;
	}
	return 0;
}
